package com.scrumtrek.trainings.tdd.model;

/**
 * Created with IntelliJ IDEA.
 * User: Vadim
 * Date: 11.09.13
 * Time: 12:39
 * To change this template use File | Settings | File Templates.
 */
public abstract class Item {
    private static long count;

    private final long id;
    private String name;
    private int price;

    {
        id = count++;
    }

    public Item() {
        this("", 0);
    }

    public Item(String name, int price) {
        this.name = name;
        this.price = price;
    }

    public long getId() {
        return id;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    @Override
    public final boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Item item = (Item) o;

        if (getId() != item.getId()) return false;

        return true;
    }

    @Override
    public final int hashCode() {
        return (int) (getId() ^ (getId() >>> 32));
    }
}
